/*
 * Copyright 2010. 
 * 
 * This document may not be reproduced, distributed or used 
 * in any manner whatsoever without the expressed written 
 * permission of xrkol Corp. 
 * 
 * $Rev: Rev $
 * $Author: Author $
 * $LastChangedDate: LastChangedDate $
 *
 */

package com.xrkol.sharelib.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xrkol.sharelib.dao.ConversationItemDao;
import com.xrkol.sharelib.entity.ConversationItem;

/**
 * @author peng.xia
 * 
 */
@Repository
public class ConversationItemDaoImpl extends BaseDaoImpl<ConversationItem, String> implements
        ConversationItemDao {

    @Override
    public List<ConversationItem> findByConversationId(String id) {
        String queryString = "from ConversationItem c where c.conversationId = ? order by createAt desc";
        return executeQueryWithPagination(queryString, null, 1, id);
    }

    @Override
    public List<ConversationItem> getUnreadItems_JS(String id) {
        String queryString = "from ConversationItem c where c.conversationId = ? "
                + "and c.isRead=false and c.isTeacherSay=false";
        return executeQueryWithoutPaging(queryString, id);
    }

    @Override
    public List<ConversationItem> findByConversationId(String id, Integer page) {
        String queryString = "from ConversationItem c where c.conversationId = ?";
        return executeQueryWithPagination(queryString, " order by createAt desc ", page, id);
    }

}
